<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发布动态</title>
    <link rel="stylesheet" href="../static/assets/css/style_detail.css">
    <!-- icons -->
    <link href="../static/assets/img/tubiao.png" rel="icon">
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 800px;
            margin: 20px auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h2 {
            margin-bottom: 20px;
            color: #333;
        }
        label {
            font-weight: bold;
        }
        input[type="text"],
        textarea,
        input[type="file"] {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            box-sizing: border-box;
        }
        textarea {
            height: 150px;
        }
        button {
            padding: 10px 20px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>发布动态</h2>
        <form id="publishForm" method="post" action="/submit_squire/{{ username }}" enctype="multipart/form-data">
            <div>
                <label for="photo">照片：</label>
                <input type="file" id="photo" name="photo" accept="image/*">
            </div>
            <div>
                <label for="content">内容：</label>
                <textarea id="content" name="content" placeholder="请输入动态内容" ></textarea>
            </div>
            <button type="submit">发布</button>
        </form>
    </div>

    <script>
        document.getElementById("publishForm").addEventListener("submit", function(event) {
            // 阻止表单默认提交行为
            event.preventDefault();

            // 获取输入框的值
            const content = document.getElementById("content").value.trim();

            // 检查内容是否为空
            if (content === "") {
                alert("内容不能为空");
                return;
            }

            // 检查内容长度是否超过 100 个字符
            if (content.length > 100) {
                alert("内容不能超过 100 个字符");
                return;
            }

            // 如果验证通过，则提交表单
            this.submit();
        });
    </script>
</body>
</html>
